package com.wannengbang.cloudleader.homepage;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gyf.immersionbar.ImmersionBar;
import com.wannengbang.cloudleader.R;
import com.wannengbang.cloudleader.base.BaseActivity;
import com.wannengbang.cloudleader.base.DataCallBack;
import com.wannengbang.cloudleader.bean.MerchantNumBean;
import com.wannengbang.cloudleader.homepage.model.HomePageModelImpl;
import com.wannengbang.cloudleader.homepage.model.IHomePageModel;
import com.wannengbang.cloudleader.utils.DateTimeUtil;
import com.wannengbang.cloudleader.widget.AppTitleBar;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 商户列表
 */
public class MerchantListActivity extends BaseActivity {


    @BindView(R.id.ll_look2)
    LinearLayout llLook2;
    @BindView(R.id.title_bar)
    AppTitleBar titleBar;
    @BindView(R.id.ll_look1)
    LinearLayout llLook1;
    @BindView(R.id.tv_gt_one_count)
    TextView tvGtOneCount;
    @BindView(R.id.tv_gt_three_count)
    TextView tvGtThreeCount;
    @BindView(R.id.ll_look3)
    LinearLayout llLook3;
    @BindView(R.id.tv_total_num)
    TextView tvTotalNum;
    @BindView(R.id.tv_look_details)
    TextView tvLookDetails;
    @BindView(R.id.tv_gt_five_count)
    TextView tvGtFiveCount;
    @BindView(R.id.tv_lt_five_count)
    TextView tvLtFiveCount;
    @BindView(R.id.ll_look0)
    LinearLayout llLook0;
    private IHomePageModel homePageModel;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_merchant_list);
        ButterKnife.bind(this);
        ImmersionBar.with(this)
                .statusBarDarkFont(false)
                .navigationBarDarkIcon(true)
                .navigationBarColor(R.color.white)
                .statusBarDarkFont(false, 0.2f)
                .init();
        initView();
        initData();
    }

    private void initView() {
        homePageModel = new HomePageModelImpl();
        titleBar.setRightClickListener(() -> {
            Intent intent = new Intent(mActivity, MerchantMonthListActivity.class);
            intent.putExtra("cycleType", "month");
            intent.putExtra("param", DateTimeUtil.getMonthDate2());
            startActivity(intent);
        });
    }

    private void initData() {
        requestGetStoreStatistics();
    }

    public void requestGetStoreStatistics() {
        homePageModel.requestReportStoreCount("", new DataCallBack<MerchantNumBean>() {
            @Override
            public void onSuccessful(MerchantNumBean bean) {
                tvLtFiveCount.setText(bean.getData().getLt_five_count() + "");
                tvGtFiveCount.setText(bean.getData().getGt_five_count() + "");
                tvGtOneCount.setText(bean.getData().getGt_one_count() + "");
                tvGtThreeCount.setText(bean.getData().getGt_three_count() + "");
                tvTotalNum.setText(String.valueOf(bean.getData().getAll_count()));
            }

            @Override
            public void onFailed(String msg, String code) {

            }
        });
    }


    @OnClick({R.id.tv_look_details, R.id.ll_look0, R.id.ll_look1, R.id.ll_look2, R.id.ll_look3})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_look_details:
                Intent intent = new Intent(mActivity, MerchantInfoListActivity.class);
                intent.putExtra("titleName", "商户列表");
                intent.putExtra("cycleType", "all");
                intent.putExtra("param", "2018-01-01");
                intent.putExtra("type", 0);
                startActivity(intent);
                break;
            case R.id.ll_look0:
                intent = new Intent(mActivity, MerchantInfoListActivity.class);
                intent.putExtra("titleName", "商户列表");
                intent.putExtra("cycleType", "all");
                intent.putExtra("param", "2018-01-01");
                intent.putExtra("type", 7);
                startActivity(intent);
                break;
            case R.id.ll_look1:
                intent = new Intent(mActivity, MerchantInfoListActivity.class);
                intent.putExtra("titleName", "商户列表");
                intent.putExtra("cycleType", "all");
                intent.putExtra("param", "2018-01-01");
                intent.putExtra("type", 1);
                startActivity(intent);
                break;
            case R.id.ll_look2:
                intent = new Intent(mActivity, MerchantInfoListActivity.class);
                intent.putExtra("titleName", "商户列表");
                intent.putExtra("cycleType", "all");
                intent.putExtra("param", "2018-01-01");
                intent.putExtra("type", 2);
                startActivity(intent);
                break;
            case R.id.ll_look3:
                intent = new Intent(mActivity, MerchantInfoListActivity.class);
                intent.putExtra("titleName", "商户列表");
                intent.putExtra("cycleType", "all");
                intent.putExtra("param", "2018-01-01");
                intent.putExtra("type", 3);
                startActivity(intent);
                break;
        }
    }
}
